﻿using DeepZoomPivotConstructor.PivotLib;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using DeepZoomPivotConstructor.VisualLib;
using System.Drawing;
using System.Linq;

namespace t_PivotLib
{
    
    
    /// <summary>
    ///This is a test class for PivotCollectionTest and is intended
    ///to contain all PivotCollectionTest Unit Tests
    ///</summary>
    [TestClass()]
    public class t_PivotCollection
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for PivotCollection Constructor
        ///</summary>
        [TestMethod]
        public void TestCTor()
        {
            PivotCollection target = new PivotCollection();
        }

        [TestMethod]
        public void TestAddImages()
        {
            Visual v = new VisualBitmapImage(1.0, 1.0, 100, Color.Black);
            PivotImage target = new PivotImage(v);
            PivotImage target1 = new PivotImage(v);

            PivotCollection c = new PivotCollection();
            c.Add(target);
            c.Add(target1);

            Assert.AreEqual(2, c.Count(), "Expected 2 items in teh list");
        }

        [TestMethod]
        public void TestAddImagesIEnum()
        {
            Visual v = new VisualBitmapImage(1.0, 1.0, 100, Color.Black);
            PivotImage target = new PivotImage(v);
            PivotImage target1 = new PivotImage(v);

            PivotCollection c = new PivotCollection() { target, target1 };
            Assert.AreEqual(2, c.Count(), "Expected 2 items in teh list");
        }

        [TestMethod]
        [ExpectedException(typeof(System.Collections.Generic.KeyNotFoundException))]
        public void TestFacetCatagoryEmptyAccess()
        {
            Visual v = new VisualBitmapImage(1.0, 1.0, 100, Color.Black);
            PivotImage target = new PivotImage(v);
            PivotCollection c = new PivotCollection() { target };

            var dude = c.FacetCatagories["name"];
        }

        [TestMethod]
        public void TestFacetCatagoryCollected()
        {
            Visual v = new VisualBitmapImage(1.0, 1.0, 100, Color.Black);
            PivotImage target = new PivotImage(v) { { "name", "fork" }, { "dude", "outthere" } };
            PivotCollection c = new PivotCollection() { target };

            c.FacetCatagories["name"].IsWordWheelVisible = false;
            c.FacetCatagories["name"].IsMetaDataVisible = false;
            c.FacetCatagories["name"].IsFilterVisible = false;

            Assert.IsTrue(c.FacetCatagories["dude"].IsWordWheelVisible, "the wheel visible is false!");
            Assert.IsTrue(c.FacetCatagories["dude"].IsMetaDataVisible, "the wheel visible is false!");
            Assert.IsTrue(c.FacetCatagories["dude"].IsFilterVisible, "the wheel visible is false!");
        }
    }
}
